from collections import namedtuple

Person = namedtuple('Person', 'name age')

bob = Person(name='Bob', age=30)
print('\nRepresentation: ', bob)

jane = Person(name='Jane', age=30)
print('\nField by name: : ', jane.name)

print('\nFields by index:')
for p in [bob, jane]:
    print('{} is {} years old'.format(*p))

# 不可变，无法设置值
jane.age = 30
